﻿
#load @"D:\Documenti\Visual Studio 2010\Projects\ssc\ExcelFunctions\Spreadsheet.fs"
#load @"D:\Documenti\Visual Studio 2010\Projects\ssc\ExcelFunctions\Functions.fs"
#r @"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll"



//let _inp1=Array.map (fun el -> try box(Double.Parse(el)) with |ex -> box(0.)) (System.IO.File.ReadAllLines(@".\test.txt"))
// let _inp2 = {new IRange with member this.Values() = Array2D.create 200 1 (box(7.)) }

open System
open Spreadsheet
open SSfunc
let inline ( *- ) x y = x*(-y)
let inline ( /- ) x y = x/(-y)
let inline ( **- ) x y = x**(-y)
let inline ( <+> ) x y = x.ToString()+y.ToString()

let spese_C2 = float 12,5
wbk.Add("spese_C2",spese_C2)
let spese_C3 = float 1,5
wbk.Add("spese_C3",spese_C3)
let spese_C4 = float 7
wbk.Add("spese_C4",spese_C4)
let spese_C5 = float 31
wbk.Add("spese_C5",spese_C5)
let spese_C2_C5 = Range("spese!C2:C5") :> IRange
wbk.Add("spese_C2_C5",spese_C2_C5)
let spese_B2 = float 2
wbk.Add("spese_B2",spese_B2)
let spese_B3 = float 12
wbk.Add("spese_B3",spese_B3)
let spese_B4 = float 4
wbk.Add("spese_B4",spese_B4)
let spese_B5 = float 1
wbk.Add("spese_B5",spese_B5)
let spese_B2_B5 = Range("spese!B2:B5") :> IRange
wbk.Add("spese_B2_B5",spese_B2_B5)
let spese_D2_D5 = 
    { new IRange with 
        member this.ValueSeq() =
            seq{
                let t_spese_C2_C5 = (Seq.windowed 1 (spese_C2_C5.ValueSeq())).GetEnumerator()
                let t_spese_B2_B5 = (Seq.windowed 1 (spese_B2_B5.ValueSeq())).GetEnumerator()
                while ( t_spese_C2_C5.MoveNext() && t_spese_B2_B5.MoveNext() && true) do
                    yield box ((t_spese_B2_B5.Current.[0]:?>float)*(t_spese_C2_C5.Current.[0]:?>float))
            }
        member this.Values() = 
            array2D (seq{ yield (this.ValueSeq()) } )
    }


let spese_D7 = Sum([spese_D2_D5])
wbk.Add("spese_D7",spese_D7)
printfn @"Spesa totale	: %O" spese_D7
Console.ReadKey(true) |> ignore
